import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src')
    }
  },
  server: {
    port: 3011,
    host: '0.0.0.0',
    open: false,
    cors: true,
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
      'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Authorization, Cache-Control',
    },
    fs: {
      allow: ['..', '../..', '../../..'],
    }
  },
  base: './',
  optimizeDeps: {
    include: [
      'vue',
      'element-plus',
      '@element-plus/icons-vue'
    ],
  },
  build: {
    lib: {
      entry: './src/main.ts',
      name: 'deployManager',
      formats: ['umd'],
      fileName: 'deployManager',
    },
    rollupOptions: {
      external: ['vue'],
      output: {
        globals: {
          vue: 'Vue',
        },
      },
    }
  }
})
